package com.eh.command;

import com.eh.command.command.Command;
import com.eh.command.command.impl.CellingFanCommand;
import com.eh.command.command.impl.CellingLightCommand;
import com.eh.command.controller.RemoteController;
import com.eh.command.electric.CellingFan;
import com.eh.command.electric.CellingLight;

/**
 * Created by David on 2016/4/29.
 */
public class CommandTest {
    public static void main(String[] args) {
        RemoteController remoteController = RemoteController.getInstance();
        Command cellingLightCommand = new CellingLightCommand(new CellingLight());
        Command cellingFanCommand = new CellingFanCommand(new CellingFan());

        remoteController.setCommand(1, cellingLightCommand);
        test1(remoteController);

        remoteController.setCommand(5, cellingFanCommand);
        test2(remoteController);
        remoteController.removeCommand(1);
        test1(remoteController);

    }

    private static void test1(RemoteController remoteController) {
        System.out.println(remoteController);
        remoteController.press(1);
        remoteController.press(1);
        remoteController.undo();
        remoteController.undo();
        remoteController.undo();
        remoteController.undo();
    }

    private static void test2(RemoteController remoteController) {
        System.out.println(remoteController);
        remoteController.press(5);
        remoteController.press(5);
        remoteController.press(5);
        remoteController.press(5);
        remoteController.undo();
        remoteController.undo();
        remoteController.undo();
        remoteController.undo();
        remoteController.undo();
    }
}
